package models

import "time"

type Doctor struct {
	Id         int       `json:"id"`
	Name       string    `json:"name"`
	Phone      string    `json:"phone"`
	Hosp       string    `json:"hosp"`
	Department string    `json:"department"`
	Title      string    `json:"title"`
	Times      time.Time `json:"time"`
	Cate       string    `json:"cate"`
	Fen        int       `json:"fen"`
}

func ListDoctor(page, pageSize int) ([]Doctor, int64, error) {
	var doctors []Doctor
	var total int64
	if err = DB.Model(Doctor{}).Count(&total).Error; err != nil {
		return nil, 0, err
	}
	if err = DB.Model(Doctor{}).Order("fen desc").Offset((page - 1) * pageSize).Limit(pageSize).Find(&doctors).Error; err != nil {
		return nil, 0, err
	}
	return doctors, total, err

}
